package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Mysql struct {
	Host     string `yaml:"host"`
	Post     int    `yaml:"post"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Dbname   string `yaml:"dbname"`
}
type AppConfig struct {
	Mysql
}

var ConFig AppConfig

func Init() {
	var err error
	viper.SetConfigFile("appconfig/dev.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		return
	}
	err = viper.Unmarshal(&ConFig)
	if err != nil {
		panic(err)
	}
	fmt.Println("配置未见加载成功：", ConFig)
}
